package com.qianfeng.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qianfeng.pojo.User;
import com.qianfeng.service.UserService;

@Controller
public class UserController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("/saveuser")
	@ResponseBody
	public String saveUser() {
		User user= new User();
		user.setName("小名");
		user.setPassword("12");
		user.setEmail("xiao.com");
		user.setBirthday(new Date());
		userService.addUser(user);
		return "ok";
	}
	
	@RequestMapping("/find/{id}")
	@ResponseBody
	public User find(@PathVariable Integer id) {
	   
		return userService.findUser(id);
	}
	
	@RequestMapping("/delete/{id}")
	@ResponseBody
	public String delete(@PathVariable Integer id) {
		
		userService.deleteUser(id);
		return "ok";
	}
}
